package edu.ptu.springboot04.config;

import edu.ptu.springboot04.interceptor.AuthInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @BelongsProject: springboot04
 * @BelongsPackage: edu.ptu.springboot04.config
 * @Author: HYJ
 * @CreateTime: 2025-03-21  21:58
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
@MapperScan("edu.ptu.springboot04.mapper")
@Import({MPConfig.class, RedisConfig.class, SecurityConfig.class})
public class SpringConfig implements WebMvcConfigurer {

    // 添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加AuthInterceptor拦截器
        registry.addInterceptor(new AuthInterceptor())
                // 拦截所有请求
                .addPathPatterns("/**")
                // 排除登录和注册请求
                .excludePathPatterns("/user/login");
    }
}
